#ifndef FUNCTION
#define FUNCTION

class Function {
public:
    virtual double operator() (double x) const = 0;
    // virtual double derivative(double x) const = 0;
    virtual double derivative(double x) const {
        // when the derivative is difficult to express, we use the difference method
        double h = 0.0001;
        double x1 = x+h;
        double x2 = x-h;
        double f1 = (x1);
        double f2 = (x2);
        double d = (f1 - f2) / (2*h);
        return d;  
    }
};

#endif